package io.lvdaxian.mybatis.mapping;

import io.lvdaxian.mybatis.session.Configuration;

import java.util.Map;

public class MappedStatement {
  
  // mapper id
  private String id;
  // 配置文件
  private Configuration configuration;
  private SqlCommandType sqlCommandType;
  private String parameterType;
  private String resultType;
  private String sql;
  private Map<Integer, String> parameter;
  
  public MappedStatement() {
  }
  
  // 建造者 模式
  public static class Builder {
    
    private final MappedStatement mappedStatement = new MappedStatement();
    
    public Builder(Configuration configuration, String id, SqlCommandType sqlCommandType, String parameterType, String resultType, String sql, Map<Integer, String> parameter) {
      mappedStatement.configuration = configuration;
      mappedStatement.id = id;
      mappedStatement.sqlCommandType = sqlCommandType;
      mappedStatement.parameterType = parameterType;
      mappedStatement.resultType = resultType;
      mappedStatement.sql = sql;
      mappedStatement.parameter = parameter;
    }
    
    public MappedStatement build() {
      assert mappedStatement.configuration != null;
      assert mappedStatement.id != null;
      return mappedStatement;
    }
  }
  
  public Configuration getConfiguration() {
    return configuration;
  }
  
  public void setConfiguration(Configuration configuration) {
    this.configuration = configuration;
  }
  
  public String getId() {
    return id;
  }
  
  public void setId(String id) {
    this.id = id;
  }
  
  public SqlCommandType getSqlCommandType() {
    return sqlCommandType;
  }
  
  public void setSqlCommandType(SqlCommandType sqlCommandType) {
    this.sqlCommandType = sqlCommandType;
  }
  
  public String getParameterType() {
    return parameterType;
  }
  
  public void setParameterType(String parameterType) {
    this.parameterType = parameterType;
  }
  
  public String getResultType() {
    return resultType;
  }
  
  public void setResultType(String resultType) {
    this.resultType = resultType;
  }
  
  public String getSql() {
    return sql;
  }
  
  public void setSql(String sql) {
    this.sql = sql;
  }
  
  public Map<Integer, String> getParameter() {
    return parameter;
  }
  
  public void setParameter(Map<Integer, String> parameter) {
    this.parameter = parameter;
  }
}
